package com.naton.common.ui

import com.wega.library.loadingDialog.LoadingDialog
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.naton.common.utils.ToastUtils

open class BaseFragment : Fragment(), ViewBehavior {
    var mLoadingDialog: LoadingDialog? = null
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        if (mLoadingDialog == null) {
            mLoadingDialog = LoadingDialog(activity!!)
        }
    }

    override fun showToast(msg: String) {
        ToastUtils.show(msg)
    }
    /**
     * 显示加载条
     */
    override fun showProgress() {
        if (mLoadingDialog != null)
            mLoadingDialog?.loading("正在加载...")
    }

    override fun hideProgress() {
        if (mLoadingDialog != null)
            mLoadingDialog?.cancel()
    }
}